Skip to content

Conversation

@jaydeluca
Copy link
Member

Related to #13468

I had been running this successfully via an intellij configuration, but the gradle command was not working due to some relative path references. This PR updates the logic to use absolute paths, which fixes the ability to run this via ./gradlew :instrumentation-docs:runAnalysis from the repo root.

It also fixes an issue where we were only parsing the contents of the first metrics file generated, but some instrumentations generate multiple files. The updated logic will combine all the entries from every file into a single list of metrics and then dedupe them by name.

@jaydeluca jaydeluca requested a review from a team as a code owner May 31, 2025 20:48
}

private static String getRepoPath() throws IOException {
URL resource = DocGeneratorApplication.class.getClassLoader().getResource("");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wdyt about passing the root directory from gradle via system property like in

systemProperty("scanPath", project.rootDir)
If the system property is not set you could assume that main class was run from intellij and there the current dir is project root.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think that is a lot cleaner, thank you for the suggestion

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The weird thing about getClassLoader().getResource("") is that afaik not all of the class loaders return anything for it. Here it would be ok, but in a real library it could cause surprises.

try (BufferedWriter writer =
Files.newBufferedWriter(
Paths.get("docs/instrumentation-list.yaml"), Charset.defaultCharset())) {
Paths.get(baseRepoPath + "docs/instrumentation-list.yaml"), Charset.defaultCharset())) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You really don't need to specify the charset. By default newBufferedWriter uses utf-8 which is what you want. Default charset could be something else.

@trask trask merged commit 760d759 into open-telemetry:main Jun 3, 2025
86 of 88 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants